/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv3.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.FeatureMap;

import org.taobao.ibatiside.model.mapperv3.Insert;
import org.taobao.ibatiside.model.mapperv3.Mapperv3Package;
import org.taobao.ibatiside.model.mapperv3.SelectKey;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Insert</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.InsertImpl#getSelectKey <em>Select Key</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.InsertImpl#getKeyColumn <em>Key Column</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.InsertImpl#getKeyProperty <em>Key Property</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.InsertImpl#isUseGeneratedKeys <em>Use Generated Keys</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class InsertImpl extends AbstractStatementImpl implements Insert {
	/**
	 * The default value of the '{@link #getKeyColumn() <em>Key Column</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getKeyColumn()
	 * @generated
	 * @ordered
	 */
	protected static final String KEY_COLUMN_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getKeyColumn() <em>Key Column</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getKeyColumn()
	 * @generated
	 * @ordered
	 */
	protected String keyColumn = KEY_COLUMN_EDEFAULT;

	/**
	 * The default value of the '{@link #getKeyProperty() <em>Key Property</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getKeyProperty()
	 * @generated
	 * @ordered
	 */
	protected static final String KEY_PROPERTY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getKeyProperty() <em>Key Property</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getKeyProperty()
	 * @generated
	 * @ordered
	 */
	protected String keyProperty = KEY_PROPERTY_EDEFAULT;

	/**
	 * The default value of the '{@link #isUseGeneratedKeys() <em>Use Generated Keys</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUseGeneratedKeys()
	 * @generated
	 * @ordered
	 */
	protected static final boolean USE_GENERATED_KEYS_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isUseGeneratedKeys() <em>Use Generated Keys</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUseGeneratedKeys()
	 * @generated
	 * @ordered
	 */
	protected boolean useGeneratedKeys = USE_GENERATED_KEYS_EDEFAULT;

	/**
	 * This is true if the Use Generated Keys attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean useGeneratedKeysESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InsertImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv3Package.Literals.INSERT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SelectKey getSelectKey() {
		return (SelectKey)getMixed().get(Mapperv3Package.Literals.INSERT__SELECT_KEY, true);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetSelectKey(SelectKey newSelectKey, NotificationChain msgs) {
		return ((FeatureMap.Internal)getMixed()).basicAdd(Mapperv3Package.Literals.INSERT__SELECT_KEY, newSelectKey, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSelectKey(SelectKey newSelectKey) {
		((FeatureMap.Internal)getMixed()).set(Mapperv3Package.Literals.INSERT__SELECT_KEY, newSelectKey);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getKeyColumn() {
		return keyColumn;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setKeyColumn(String newKeyColumn) {
		String oldKeyColumn = keyColumn;
		keyColumn = newKeyColumn;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.INSERT__KEY_COLUMN, oldKeyColumn, keyColumn));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getKeyProperty() {
		return keyProperty;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setKeyProperty(String newKeyProperty) {
		String oldKeyProperty = keyProperty;
		keyProperty = newKeyProperty;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.INSERT__KEY_PROPERTY, oldKeyProperty, keyProperty));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isUseGeneratedKeys() {
		return useGeneratedKeys;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUseGeneratedKeys(boolean newUseGeneratedKeys) {
		boolean oldUseGeneratedKeys = useGeneratedKeys;
		useGeneratedKeys = newUseGeneratedKeys;
		boolean oldUseGeneratedKeysESet = useGeneratedKeysESet;
		useGeneratedKeysESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.INSERT__USE_GENERATED_KEYS, oldUseGeneratedKeys, useGeneratedKeys, !oldUseGeneratedKeysESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetUseGeneratedKeys() {
		boolean oldUseGeneratedKeys = useGeneratedKeys;
		boolean oldUseGeneratedKeysESet = useGeneratedKeysESet;
		useGeneratedKeys = USE_GENERATED_KEYS_EDEFAULT;
		useGeneratedKeysESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, Mapperv3Package.INSERT__USE_GENERATED_KEYS, oldUseGeneratedKeys, USE_GENERATED_KEYS_EDEFAULT, oldUseGeneratedKeysESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetUseGeneratedKeys() {
		return useGeneratedKeysESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv3Package.INSERT__SELECT_KEY:
				return basicSetSelectKey(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv3Package.INSERT__SELECT_KEY:
				return getSelectKey();
			case Mapperv3Package.INSERT__KEY_COLUMN:
				return getKeyColumn();
			case Mapperv3Package.INSERT__KEY_PROPERTY:
				return getKeyProperty();
			case Mapperv3Package.INSERT__USE_GENERATED_KEYS:
				return isUseGeneratedKeys();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv3Package.INSERT__SELECT_KEY:
				setSelectKey((SelectKey)newValue);
				return;
			case Mapperv3Package.INSERT__KEY_COLUMN:
				setKeyColumn((String)newValue);
				return;
			case Mapperv3Package.INSERT__KEY_PROPERTY:
				setKeyProperty((String)newValue);
				return;
			case Mapperv3Package.INSERT__USE_GENERATED_KEYS:
				setUseGeneratedKeys((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv3Package.INSERT__SELECT_KEY:
				setSelectKey((SelectKey)null);
				return;
			case Mapperv3Package.INSERT__KEY_COLUMN:
				setKeyColumn(KEY_COLUMN_EDEFAULT);
				return;
			case Mapperv3Package.INSERT__KEY_PROPERTY:
				setKeyProperty(KEY_PROPERTY_EDEFAULT);
				return;
			case Mapperv3Package.INSERT__USE_GENERATED_KEYS:
				unsetUseGeneratedKeys();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv3Package.INSERT__SELECT_KEY:
				return getSelectKey() != null;
			case Mapperv3Package.INSERT__KEY_COLUMN:
				return KEY_COLUMN_EDEFAULT == null ? keyColumn != null : !KEY_COLUMN_EDEFAULT.equals(keyColumn);
			case Mapperv3Package.INSERT__KEY_PROPERTY:
				return KEY_PROPERTY_EDEFAULT == null ? keyProperty != null : !KEY_PROPERTY_EDEFAULT.equals(keyProperty);
			case Mapperv3Package.INSERT__USE_GENERATED_KEYS:
				return isSetUseGeneratedKeys();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (keyColumn: ");
		result.append(keyColumn);
		result.append(", keyProperty: ");
		result.append(keyProperty);
		result.append(", useGeneratedKeys: ");
		if (useGeneratedKeysESet) result.append(useGeneratedKeys); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //InsertImpl
